﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.quest.Display {
    import Events.*;
    import Display.DialogUI.*;
    import Classes.*;

    public class QuestMiniGameCompleteDialog extends GenericDialog {

        protected var m_popupData:Object;

        public function QuestMiniGameCompleteDialog(_arg1:Object, _arg2:Boolean=true){
            this.m_popupData = _arg1;
            var _local3:String = ZLoc.t("Quest", (_arg1.name + "_dialog_share_btn_text"));
            var _local4:String = ("QuestMiniGameComplete_" + _arg1.name);
            var _local5:String = this.getRewardList(_arg1);
            var _local6:Object = {
                score:_arg1.minigameResults.score,
                rewardList:_local5
            };
            var _local7:String = ZLoc.t("Dialogs", (_local4 + "_message"), _local6);
            super(_local7, "MiniGameComplete", GenericDialogView.TYPE_CUSTOM_OK, this.onComplete, _local4, _arg1.finishIcon, true, 0, "", null, _local3);
        }
        protected function getRewardList(_arg1:Object):String{
            var _local4:Object;
            var _local5:String;
            var _local6:Item;
            var _local2 = "";
            var _local3:int;
            while (_local3 < _arg1.rewards.length) {
                _local4 = _arg1.rewards[_local3];
                if (_local4["resource"] != "xpromo"){
                    _local5 = ZLoc.t("Quest", ("reward_" + String(_local4.resource)), {amount:int(_local4.amount)});
                    if (((!((_local4.itemName == null))) && (!((_local4.itemName == ""))))){
                        _local6 = Global.gameSettings.getItemByName(_local4.itemName);
                        _local5 = _local6.localizedName;
                    };
                    if (((!((_local4.loc == ""))) && (!((_local4.loc == null))))){
                        _local5 = ZLoc.t("Dialogs", _local4.loc, {reward:_local5});
                    };
                };
                _local2 = (_local2 + _local5);
                if (_local3 < (_arg1.rewards.length - 1)){
                    _local2 = (_local2 + ", ");
                };
                _local3++;
            };
            return (_local2);
        }
        protected function onComplete(_arg1:GenericPopupEvent):void{
            var _local2:String = ZLoc.t("Quest", (this.m_popupData.name + "_dialog_title"));
            if (_arg1.button == GenericDialogView.YES){
                Global.world.viralMgr.sendQuestCompleteFeed(Global.player, this.m_popupData.name, _local2);
            };
        }
        override public function isLockable():Boolean{
            return (true);
        }

    }
}//package Modules.quest.Display 
